import axios from '@/libs/api.request'

export const addRepo = (data) => {
  return axios.request({
    url: 'system/registry/',
    data,
    method: 'post'
  })
}

export const repoList = (params) => {
  return axios.request({
    url: 'system/registry/',
    params,
    method: 'get'
  })
}

export const connectStatus = (id) => {
  return axios.request({
    url: 'system/connect/',
    params: {
      'id': id
    },
    method: 'get'
  })
}

export const deleteRepo = (id) => {
  return axios.request({
    url: `system/registry/${id}/`,
    method: 'delete'
  })
}

export const updateRepo = (id, data) => {
  return axios.request({
    url: `system/registry/${id}/`,
    data,
    method: 'patch'
  })
}

export const robotList = () => {
  return axios.request({
    url: 'system/dtalk/',
    method: 'get'
  })
}

export const robotCreate = (data) => {
  return axios.request({
    url: 'system/dtalk/',
    data,
    method: 'post'
  })
}

export const robotDelete = (id) => {
  return axios.request({
    url: `system/dtalk/${id}`,
    method: 'delete'
  })
}

export const robotTest = (id) => {
  return axios.request({
    url: `system/robot/connect/${id}/`,
    method: 'get'
  })
}

export const robotUpdate = (id, data) => {
  return axios.request({
    url: `system/dtalk/${id}/`,
    data,
    method: 'patch'
  })
}

export const authGroupCreate = (data) => {
  return axios.request({
    url: 'auth_group/',
    data,
    method: 'post'
  })
}

export const authGroupUpdate = (id, data) => {
  return axios.request({
    url: `auth_group/${id}/`,
    data,
    method: 'put'
  })
}

export const authGroupList = () => {
  return axios.request({
    url: 'auth_group/',
    method: 'get'
  })
}

export const authGroupDelete = (id) => {
  return axios.request({
    url: `auth_group/${id}/`,
    method: 'delete'
  })
}

export const userList = (params) => {
  return axios.request({
    url: 'users/',
    params,
    method: 'get'
  })
}

export const userAdd = (data) => {
  return axios.request({
    url: 'users/',
    data,
    method: 'post'
  })
}

export const userUpdatePass = (id, data) => {
  return axios.request({
    url: `account/${id}/`,
    data,
    method: 'put'
  })
}

export const userDelete = (id) => {
  return axios.request({
    url: `users/${id}/`,
    method: 'delete'
  })
}

export const authGroupUserAuth = (data) => {
  const params = {
    'auth_groups': data + ''
  }
  return axios.request({
    url: 'auth_group/user_auth/',
    params,
    method: 'get'
  })
}

export const authGroupUserAuthUpdate = (id, data) => {
  return axios.request({
    url: `users/${id}/`,
    data,
    method: 'patch'
  })
}

export const ldapUserAuthGroupGet = () => {
  return axios.request({
    url: `ldap_admin/`,
    method: 'get'
  })
}

export const ldapUserAuthGroup = (id, data) => {
  return axios.request({
    url: `ldap_admin/${id}/`,
    data,
    method: 'patch'
  })
}

export const ldapConnectTest = (params) => {
  return axios.request({
    url: 'ldap_test/',
    params,
    method: 'get'
  })
}
